Tx  Function:
While (file has data to send)
{
	start Random Wait Timer()
	while(receiving variable is false)
	{
		bid for line
		start txAck timer
		if(received ack)
		{
			set Writting variable to true
			create the frame
			while(frame counter is less than max)
			{
				start txAck timer
				send frame to the port
				if(timer expires)
				{
					increment frame counter
				}
				else
				{
					reset tx Variables
					set Delay timer
				}
			}
		}
	}
}

Rx Function  (called when an ENQ char is read at the port)
{

	set receiving variable to true

	write ACK char to port

	start rxFrame timer
	while(timer hasn't expired)
	{
		while (true)
		{
			wait for frame to be read
			check for errors
			if (there's no error)
				break
		}
		
		Kill rxFrame timer
	}
	proccess frame
	write ACK char to port
	reset rx Variables
	start random wait timer
	return
}

reset tx Variables function
{
	frame counter -> 0
	writing -> false
	frameTypeWritten++
	
}

reset rx Variables function
{
	reading -> false
	frameTypeWritten++
	
}

processFrame function
{
	compare frame type sent and frame type expected
	if(expecting the frame received)
	{
		get the data
		display Data
	}
}

Create Frame function
{
	get 1000 bytes of data in array at index 2
	insert STX char and frame type send chars at front of array
	append CRC bytes to array
}

Notes:

The initial random wait time on the rx side is called in at the start of the read thread, before the port monitoring begins.

Port writes frame to a global variable, which can is monitored until writing is completed.

